{extend name="Public:base" /}
{block name="main"}
<main>
	<!-- breadcrumb-area-start -->
	<!-- <section class="breadcrumb-area" data-background="img/bg/page-title.png">
		<div class="container">
			<div class="row">
				<div class="col-xl-12">
					<div class="breadcrumb-text text-center">
						<h1>Registeration</h1>
						<ul class="breadcrumb-menu">
							<li><a href="index.html">home</a></li>
							<li><span>Registeration</span></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</section>
	 --><!-- breadcrumb-area-end -->

	<!-- login Area Strat-->
	<section class="login-area pt-100 pb-100">
		<div class="container">
			<div class="row">
				<div class="col-lg-8 offset-lg-2">
					<div class="basic-login">
						<h3 class="text-center mb-60">Register From Here</h3>
						<form action="#">
							<label for="name">Email Address Or Phone <span>**</span></label>
							<input id="name" type="text" placeholder="Enter Username or Email address..." />
							<label for="pass">Password <span>**</span></label>
							<input id="pass" type="password" placeholder="Enter password..." />
							<button type="button" class="btn theme-btn w-100" onclick="registerUser()">Register Now</button>
						</form>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- login Area End-->
</main>
{/block}
{block name="script"}
<script>
	//获取产品信息
	function registerUser() {
		console.log("login")
		let ajax = new Services();
		// var form_data = $("#formlogin").SerializeArray();
		var data = {
			name:$("#name").val(),
			pass:$("#pass").val()
		}
		console.log(data);
		ajax.postExample("/index/registerUser", data,
			function(res) {
				if(res.code == 200) {
					//注册成功
					TS.successAlert("register success");
					//保存token,user,username
					$.cookie("token",res.data.token, { path: '/' });
					$.cookie("username",res.data.user.userName, { path: '/' });
					$.cookie("is_wholesale",res.data.user.is_wholesale, { path: '/' });
					$.cookie("user",JSON.stringify(res.data.user), { path: '/' });
					//保存信息之后跳转到首页
					window.location.href = "/";
				}else {
					//错误提示
					TS.errorAlert(res.error);
				}
			},
			function(e) {
				console.log("222", e);
			}
		)
	}
</script>
{/block}
